package com.javabasic.algorithm.leetcode;

/**
 * @author xiongmin
 * @version 0.0.1
 * @description Created by work on 2021/11/7 9:11 下午
 * @see [598. Range Addition II](https://leetcode-cn.com/problems/range-addition-ii/)
 */
public class RangeAdditionII {

    /**
     * 逻辑思维题：我们只需要找到一直在增加的那个矩形即可，即min(x)*min(y)
     * @param m
     * @param n
     * @param ops
     * @return
     */
    public int maxCount(int m, int n, int[][] ops) {
        int len = ops.length;
        int maxX = m, maxY = n;
        for (int i = 0; i < len; i++) {
            if (ops[i][0] < maxX) {
                maxX = ops[i][0];
            }
            if (ops[i][1] < maxY) {
                maxY = ops[i][1];
            }
        }
        return maxX * maxY;
    }
}
